<template>
  <div class='app-container'>
    <div class='unit-ment'>
      <div class="unit-tabs">
        <div class="tabs1">
          <router-link :to="{name:'manageIndex'}">手工发放</router-link>
        </div>
        <div class="tabs2 unit-tabs-act">
          <router-link :to="{name:'entry2',query:{tab:'entry'}}">Excel导入发放</router-link>
        </div>
      </div>
      <div>
        <div v-show="tab == '1'">
        <div class='singleLayout'>
          <div class='layout1 clearfix'>
            <el-form label-width="120px" :model="formLabel" :rules="rules" ref="formLabel">
              <!-- <el-form-item label="手机号" prop='phonenumber'>
                <el-input class='wd230' size='mini' v-model='formLabel.phoneNumber '></el-input>
              </el-form-item> -->
              <el-form-item label="企业帐户余额">
                <el-input size='mini' v-model="balance" :disabled="true" class='wd250'></el-input>&nbsp;&nbsp;元
              </el-form-item>
              <el-form-item label="姓名" prop='name' class='formPlace'>
                <el-input size='mini' v-model='formLabel.name'></el-input><a class='links placeChange' @click='searchPayee'>搜索收款人</a>
              </el-form-item>
                <el-dialog  :visible.sync="dialogTable" title='搜索收款人' center  style='margin-bottom:15px' @close='closePayee'>
                <div class="formSearchDiv searchtxtdiv wd230"><el-input class="searchtxtinput wd230" v-model='searchTxt' type='text' placeholder='请输入手机号/姓名/身份证号' size='mini'></el-input></div>
                <div class="formSearchDiv searchdata">
                    <el-button type='primary' size='mini' @click='searchDialog'>搜索</el-button>
                </div>
                <el-table ref="singleTable" :data="userList" style="width: 100%"  :stripe='true' 
                 class="payuserTbale"  highlight-current-row='bhighlight'  @current-change="radioChange" >
                <el-table-column label="" prop="name" width='60px'>
                    <template slot-scope='scope' >
                      <el-radio v-model='radio'  :label="scope.row.id">&nbsp;</el-radio>
                    </template>
                </el-table-column>
                <el-table-column label="姓名" prop="name" width="80px">
                    <template slot-scope='scope'>
                        <span v-if="scope.row.name!=''">{{scope.row.name}}</span>
                        <span v-if="scope.row.name==''">-</span>
                    </template>
                </el-table-column>
                <el-table-column label="手机号" width='220px'>
                    <template slot-scope='scope'>
                        <span v-if="scope.row.phoneNumber!=''">{{scope.row.phoneNumber}}</span>
                        <span v-if="scope.row.phoneNumber==''">-</span>
                    </template>
                </el-table-column>
                <el-table-column label="身份证号" width='220px'>
                    <template slot-scope='scope' >
                        <span v-if="scope.row.identityCard!=''">{{scope.row.identityCard}}</span>
                        <span v-if="scope.row.identityCard==''">-</span>
                    </template>
                </el-table-column>
                <el-table-column label="注册状态" prop="" width='100px'>
                    <template slot-scope='scope'>
                        <span v-if="scope.row.registrationState==0">
                            <i class="icon iconfont icon-icon01"  style="color:#389E0D"></i>
                            成功
                        </span>
                       <!--  <span v-if="scope.row.registrationState==1">
                            <i class="icon iconfont icon-icon01" style="color:#FF7819"></i>
                            待完善
                        </span> -->
                    </template>
                </el-table-column>
               
                
              </el-table>
               <div v-if="userList.length!=0" class='page-right clearfix'>
                <el-pagination @current-change="handleCurrent" :current-page='currentPage3' background :page-size="10" layout="total,prev, pager, next" :total="pagetotal" class='util-page' size='mini'></el-pagination>
              </div>
              <div class='ensurebtn'>
                <el-button type='button' class=' el-button el-button--primary el-button--small'  @click='saveData'>确定</el-button>
              </div>
                </el-dialog>
              
              <el-form-item label="手机号" prop='phoneNumber'>
                <el-input size='mini' v-model='formLabel.phoneNumber'></el-input>
              </el-form-item>
              <el-form-item label="身份证号" prop='identityCard'>

                <el-input size='mini' v-model='formLabel.identityCard'></el-input>
              </el-form-item>
             <!--  <el-form-item label="姓名" prop='name'>
                <el-input size='mini' v-model='formLabel.name'></el-input>
              </el-form-item> -->
              <el-form-item label="金额" prop='money'>
                <el-input size='mini' v-model='formLabel.money' @change="changeBalance"></el-input>
              </el-form-item>
              <el-form-item label="备注" prop='remark'>
                <el-input type="textarea" v-model='formLabel.remark' class='area'></el-input>
              </el-form-item>
              <!--  <el-form-item label="验证码" prop='code'>
                <el-input class='wd180' size='mini' v-model='formLabel.code'></el-input>
                <el-button  @click='getnumber' size='mini'>获取验证码</el-button>
              </el-form-item> -->
              <!--  <el-form-item label="" prop='' style="margin-top: -30px;color: #999999;">
                <p>请使用手机138****2345获取验证码</p>
              </el-form-item> -->
              <div class='define'>
                <el-button type='button' @click="determine('formLabel')" class='btn1 el-button el-button--primary el-button--small' >确定</el-button>
              </div>
            </el-form>
          </div>
          <div class='bottom'>
            <!-- <el-button type='button' @click="determine('formLabel')" class='btn1 el-button el-button--primary el-button--small' >确定</el-button> -->
            <el-dialog title="佣金发放" :visible.sync="centerDialogVisible" width="500px" center @close='closeDialog'>
              <!-- <span class='check'>校验信息正确，确定要转账？</span> -->
              <el-form :rules='ruels3' :model="leadLabel" ref="leadLabel" class='getcheck1' label-width='80px'>
                 <el-form-item label="支付密码" prop='payPassword'>
                  <el-input class='wd180' size='mini' v-model='leadLabel.payPassword' type='password'></el-input>
                </el-form-item>
                <el-form-item label="验证码" prop='code'>
                  <el-input class='wd180' size='mini' v-model='leadLabel.code'></el-input>
                  <el-button @click='countDown' :disabled="!show1" size='mini'>
                    <span v-show="show1">获取验证码</span>
                    <span v-show="!show1" class="count">{{count1}} s</span>
                  </el-button>
                 <div class="setColor">请使用手机{{phone}}获取验证码</div>
                </el-form-item>
              </el-form>
              <span slot="footer" class="dialog-footer">
                <el-button type="primary" size='small' @click="submitForm('leadLabel')" :loading='ensureloading'>提交</el-button>
              </span>
            </el-dialog>
            <el-dialog
              title="提示"
              :visible.sync="dialogHeader"
              width="30%"
              center :show-close="false">
              <div class="up-img">
                    <img src="../../assets/images/success.png"/>
              </div>
              <div class="up-text">转账成功!</div>
              <span slot="footer" class="dialog-footer">
                <el-button @click="fafang" size='small'>继续发放</el-button>
                <el-button type="primary" @click="toDetail" size='small'>查看账单</el-button>
              </span>
            </el-dialog>
          </div>
        </div>
        </div>
        <div v-show="tab == '2'">
          <div class='layout'>
            <div class='biaoge'>
              <!-- <div class='genblance'><span>企业一般户余额&nbsp;{{balance}}&nbsp;元</span></div> -->
              <el-form :model="ruleForm" :rules="rules2" ref="ruleForm" class="demo-ruleForm" label-width='120px'>
                <el-form-item label="企业帐户余额">
                  <el-input size='mini' v-model="balance" class='wd250' :disabled="true"></el-input>&nbsp;&nbsp;元
                </el-form-item>
                <!-- <div class='file'>
                <span class='daoru'>导入文件</span>
              </div> -->
                <!-- <div class='model'> -->
                <!--   <el-form-item> -->
                <!-- <div class='file'>
                    <span class='daoru'>导入文件</span>
                </div> -->
                <div class='model'>
                  <el-form-item label="导入文件" prop="filePath">
                    <el-input type="hidden" v-model="ruleForm.filePath" style='display:none'></el-input>
                    <el-upload class="upload-demo lead" :action="url" :headers="headers" :on-success="loadSuc" multiple :before-upload="beforeAvatarUpload" accept="excel/xls,excel/xlsx" :on-remove='removeFile' ref='uploadText' :on-exceed="handleExceed" :limit="1">
                      <div slot="tip" class="el-upload__tip">只能上传xlsx、xls文件</div>
                      <div slot="tip" class="downloadModel">还没有模板，点击<a :href="basedown" class='links'>下载模板</a></div>
                      <el-button size="mini">
                        <i class='el-icon-upload'></i> 点击上传</el-button>
                    </el-upload>
                      <div v-show='showfile' class='model-message'>{{errormessage}}<a :href="filepath" v-if='filepath' class='links'>下载文件</a><span v-if='filepath' class='model-message'>查看详情</span></div>
                  </el-form-item>
                  <!-- </div>  -->
                  <el-form-item label="备注" prop="remarks">
                    <el-input type="textarea" v-model="ruleForm.remarks" class='wd230 area'></el-input>
                  </el-form-item>
                  <el-form-item label="支付密码" prop='payPassword'>
                    <el-input class='wd230' size='mini' v-model='ruleForm.payPassword' type='password'></el-input>
                  </el-form-item>
                  <el-form-item label="短信验证码" prop="code">
                    <el-input v-model="ruleForm.code" class='wd230 verification' size='mini'></el-input>
                    <el-button @click='getnumber2' :disabled="show2" size='mini'>
                      <span v-show="show" >获取验证码</span>
                      <span v-show="!show" class="count">{{count}} s</span>
                    </el-button>
                    <div style='color: #999'>请使用手机{{phone}}获取验证码</div>
                  </el-form-item>
                </div>
              </el-form>
              <div class='btn2'>
                <el-button type='button' @click="submitSecond('ruleForm')" class='btn1 el-button el-button--primary el-button--small' :loading="btnloading" :disabled='show3'>确定</el-button>
                <!-- <el-dialog title="提示" :visible.sync="centerDialogVisible2" width="30%" center>
                  <span v-if='centerDialogVisible2==true'>转账成功！</span>
                  <span v-if='centerDialogVisible2==false'>{{errorMessage}}</span>
                  <span slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="centerDialogVisible2 = false">确 定</el-button>
                  </span>
                  <el-form>
                  </el-form>
                </el-dialog> -->
              </div>
            </div>
          </div>
          <!--  <div class='btn2'>
            <el-button type='button' @click="submit('ruleForm')" class='btn1 el-button el-button--primary el-button--small' >确定</el-button>
            <el-dialog title="提示" :visible.sync="centerDialogVisible2" width="30%" center>
              <span v-if='centerDialogVisible2==true'>转账成功！</span>
              <span v-if='centerDialogVisible2==false'>{{errorMessage}}</span>
              <el-form>
              </el-form>
              <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submit('ruleForm')">确定</el-button>
              </span>
            </el-dialog>
          </div> -->
          <el-dialog
              title="提示"
              :visible.sync="dialogHeader2"
              width="30%"
              center :show-close="false">
              <div class="up-img">
                    <img src="../../assets/images/success.png"/>
              </div>
              <div class="up-text">佣金发放成功!</div>
              <span slot="footer" class="dialog-footer">
                <el-button @click="fafang2" size='small'>继续发放</el-button>
                <el-button type="primary" @click="toDetail" size='small'>查看账单</el-button>
              </span>
            </el-dialog>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
const TIME_COUNT = 60;


var nubalanceData;
import { getToken, removeToken } from '@/utils/auth'
export default {

  data() {
    var checkmoney= (rule, value, callback) => {
        if (parseFloat(value)>nubalanceData) {
          return callback(new Error('可输入的金额需小于企业账户余额'));
        }else{
            return callback();
        }}
    return {
      bchange: false,
      bhighlight: false,
      btnloading:false,
      receive:'',
      dialogTable:false,
      dialogHeader2:false,
      currentPage3:1,
      tab: "1",
      resource:'',
      searchTxt:'',
      centerDialogVisible: false,
      phone:null,
      phone2:null,
      dialogHeader:false,
      showfile:false,
      path: '',
      errorMessage: '',
      userList:[],
      filepath:null,
      currentPage: 1,
      radio: null,
      pagetotal: null,
      formLabel: {
      	phoneNumber:'',
      	name:'',
      	identityCard:''
      },
      smsNumber: '',
      ensureloading:false,
      ruleForm: {},
      leadLabel: {},
      show: true,
      show2: true,
      show1: true,
      show3: false,
      count: '',
      count1: '',
      timer: null,
      valData:'',
      timer1: null,
      errrormessage: '',
      dialogVisible: false,
     // toFull:this.tofull,
      balance: '',
      centerDialogVisible2: false,
      smsmessage:'',
      url:process.env.BASE_API+'services/TransferAccountBatchsUpload?templateCode=1',
      list: [],
      securitycode2: null,
      securitycode: null,
      basedown:process.env.BASE_DOWN+'/Templates/TransferAccountBatchsTemplate.xlsx',
      rules: {
        phoneNumber: [
          { required: true, message: '请填写手机号', trigger: 'blur' },
        ],
        identityCard: [
          { required: true, message: '请填写身份证号', trigger: 'blur' },
        ],
        name: [
          { required: true, message: '请填写姓名', trigger: 'blur' },
        ],
        money: [
          { required: true, message: '请填写金额', trigger: 'blur' },
          { validator: checkmoney, trigger: 'blur' }
        ],

           
        remark: [
          { required: true, message: '请填写备注', trigger: 'blur' },
          { min: 0, max: 20, message: '长度在 0到 20个字符', trigger: 'blur' }
        ],
        code: [
          { required: true, message: '请填写验证码', trigger: 'blur' },
        ],


      },
      ruels3: {
        payPassword:[{required: true, message: '请填写支付密码', trigger: 'blur'}],
        code: [
          { required: true, message: '请填写验证码', trigger: 'blur' },
        ],
      },
      rules2: {
        remarks: [
          { required: true, message: '请填写备注', trigger: 'blur' },
          { min: 0, max: 20, message: '长度在 0到 20个字符', trigger: 'blur' }
        ],
        payPassword:[{required: true, message: '请填写支付密码', trigger: 'blur'}],
        code: [
          { required: true, message: '请填写验证码', trigger: 'blur' },
        ],
        filePath: [
          { required: true, message: '请上传文件', trigger: 'blur' },
        ],
      },
      trdata:{},
      id:'',
    }
  },
  computed:{
    headers(){
      return {
        'Authorization':'Bearer ' + getToken()
      }
    }
  },
  mounted() {
  	this.pasOr()
    this.AdminInfo()
    if (this.$route.query.id) {
      this.userinfo()
    }
     let tab = this.$route.query.tab;
      if (tab) {
        if (tab == "entry") {
          this.tab = '2'

        } 
      } else {
        this.tab = '1'
      } 
  },

  watch:{
        $route(to,from){
        let tab = this.$route.query.tab;
          if (tab) {
            if (tab == "entry") {
              this.tab = '2'
              // this.tofull2();
              this.pasOr();
            } 
          } else {
            this.tab = '1'
            // this.tofull2();
            this.pasOr()
          }
        
    }
},
  created() {
  	this.id = this.$route.query.id;
    this.getBalance();
    // this.userinfo();
    this.getuserList()
    //this.getCurrentRow()
  },

  methods: {
  	pasOr(){
			let params = {};
			this.post(params,'services/app/applets/CheckEnterpriseSetPwd').then(res=>{
				if (res.success) {
					if (res.result.hadPwd==false) {
						this.tofull2();
					}
				}
			})
		},
    tofull2(){
            this.$confirm('您还没有设置支付密码，是否设置?', '提示', {
              confirmButtonText: '马上设置',
              cancelButtonText: '以后再说',
              type: 'warning',
              closeOnClickModal:false,
            }).then(() => {
              this.$router.push({
                name:'paysetpwd',
                query:{}
              })
            }).catch(() => {
               console.log('catch')        
            });     
        },
    fafang(){
        this.$router.push({
            name: 'paytransferMenu',

        })
        this.$router.go(0)
    },
    fafang2(){
        this.$router.push({
            name:'entry2',
            query:{
                id: this.$route.query.entry,
                tab:'entry'
            }
        })
        this.dialogHeader2=false;
        this.timer1 = clearInterval(this.timer1);
        this.show= true;
    },
    toDetail(){
        this.$router.push({
            name:'putout',
        })
    },
    searchPayee(){
        this.valData='';
        this.dialogTable=true
        // this.bchange=false;
        this.radio=null;
        this.getuserList()


    },
   //获取用户列表
    getuserList(pageindex){
            this.loading = true;
            let params = {
                keyWord: this.searchTxt,
                pageIndex:pageindex,
                state:0,
            }
            this.post(params, "services/app/applets/AppUsers").then(response => {
                this.loading = false;
                if (response.success) {
                    console.log(response.result.items)
                    this.userList = response.result.items;
                    this.pagetotal = response.result.totalCount;
                   if (pageindex) {
                        this.currentPage3= pageindex;
                      } else {
                        this.currentPage3= 1;
                      }
                }
            });
        },
    closePayee(){
        this.searchTxt='',
        this.getuserList();
    },
    radioChange(val){
        // console.log(val);
        // if(val.id == this.radio){
        //     this.$refs.singleTable.setCurrentRow(row);
        // }else{
        //      this.valData=val.id;
        //      this.radio = val.id
        // }
        // console.log(this.radio)
        // this.bchange=true
        this.$refs.singleTable.setCurrentRow(val);
        this.valData=val.id;
        this.radio = val.id 
        console.log(val.id)
       
       // this.trdata = val;

        // this.formLabel.phoneNumber=val.phoneNumber
        // this.formLabel.name=val.name
        // this.formLabel.identityCard=val.identityCard
        
    },
    saveData(){
        // let data = this.trdata
        
        // this.formLabel.phoneNumber = data.phoneNumber
        // this.formLabel.name=data.name
        // this.formLabel.identityCard=data.identityCard
     // this.$router.push({
     //     name:'entry1',
     //     query:{
     //         id:this.valData
     //     }
     // })
     if(this.valData!=''){
        this.id = this.valData;
        this.userinfo();
     }else{
        this.formLabel.phoneNumber ='';
        this.formLabel.name = '';
        this.formLabel.identityCard ='';
     }
	    this.dialogTable=false;
        this.searchTxt='',
        this.getuserList();

    },
    handleCurrent(val){
        this.getuserList(val)
    },
    searchDialog(){
        this.getuserList();
    },
    closeDialog(){
        this.leadLabel.payPassword='';
        this.leadLabel.code='';
        this.timer1 = clearInterval(this.timer1);
        // this.count1 = TIME_COUNT;
        this.show1= true;
        // this.show2=true;
    },
    clickone(type) {
      //this.tab = types;
      if (type == "1" || type == "undefined") {
        this.$router.push({ name: "entry1", query: { tab: "" } });
      } else if (type == "2") {
        this.$router.push({ name: "entry2", query: { tab: "entry" } });
      } 
    },
    removeFile() {
      this.ruleForm.filePath = ""
      this.show2=true;
      this.showfile=false;
    },
    numFilter(val) {
      // 截取当前数据到小数点后两位
      // let realVal = Number(val).toFixed(2)
      // num.toFixed(2)获取的是字符串
      // return Number(realVal)
      if (val || val == 0) {
        val = val.toString().replace(/\$|\,/g, '');
        if (isNaN(val)) {
          val = "0";
        }
        let sign = (val == (val = Math.abs(val)));
        val = Math.floor(val * 100 + 0.50000000001);
        let cents = val % 100;
        val = Math.floor(val / 100).toString();
        if (cents < 10) {
          cents = "0" + cents
        }
        for (var i = 0; i < Math.floor((val.length - (1 + i)) / 3); i++) {
          val = val.substring(0, val.length - (4 * i + 3)) + ',' + val.substring(val.length - (4 * i + 3));
        }

        return (((sign) ? '' : '-') + val + '.' + cents);
      }
    },
    //金额
    clearNoNums(obj) {
            obj = obj.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
            obj = obj.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
            obj = obj.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
           // obj = obj.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3"); //只能输入两个小数
            if(obj.indexOf(".") < 0 && obj != "") {
                //以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
                obj = parseFloat(obj);
            }
            if(obj == "") {
                obj = 0
            }
            //this.formLabel.money = obj
            console.log(obj)
            return obj

        },
    changeBalance(val){
            // console.log(val);
            // let a = this.formLabel.money//输入的金额
            // if(a>nubalanceData){
            //     this.formLabel.money=this.numFilter(nubalanceData);
            // }
        },
    // 倒计时2
    getnumber2() {
      console.log(this.show)
      if (!this.timer) {
        this.count = TIME_COUNT;
        this.show= false;
        this.show2=true;
        this.show3=false;
        // this.$message.success('验证码已发送，请注意查收');
        this.getnumber3();
        this.timer = setInterval(() => {
          if (this.count > 0 && this.count <= TIME_COUNT) {
            this.count--;
          } else {
            this.show = true;
            this.show2=false;
            this.show3=false;
            clearInterval(this.timer);
            this.timer = null;
          }
        }, 1000)
      }
    },
    // 倒计时1
    countDown() {
      console.log(this.show1)
      if (!this.timer1) {
        this.count1 = TIME_COUNT;
        this.show1 = false;
        // this.$message.success('验证码已发送，请注意查收');
        this.getnumber();
        this.timer1 = setInterval(() => {
          if (this.count1 > 0 && this.count1 <= TIME_COUNT) {
            this.count1--;
          } else {
            this.show1 = true;
            clearInterval(this.timer1);
            this.timer1 = null;
          }
        }, 1000)
      }
    },
    beforeAvatarUpload(file) {
      let testmsg = file.name.substring(file.name.lastIndexOf(".") + 1);
      const isexcel = testmsg === "xls";
      const excel = testmsg === "xlsx";
      console.log(file);
      // const isexcel = file.type === 'excel/xlsx';
      //  const excel = file.type === 'excel/xls';
      if (!isexcel && !excel) {
        // this.excelFileName.push(file.name);
        this.$confirm("上传文件暂时只支持xlsx和xls格式", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "error",
          callback: action => {
            // this.$refs.form.resetFields();

            this.$emit("closeEditUpload");
          }
        });
      }
      return isexcel || excel;
    },
    loadSuc(val) {
    if(val.state == 1&&val.filePath!=''){
                    // this.$notify.error({
                    //    title: '错误',
                    //    message:val.errorMessage
                    // });
                    if(val.errorCode==0){
                      this.errormessage='模板不匹配，请下载正确的模板'  
                    }else if(val.errorCode==1){
                        this.errormessage='数据不匹配，'
                    }else if(val.errorCode==2){
                        this.errormessage='发放总金额超出账户余额'
                    }else if(val.errorCode==3){
                        this.errormessage='文件类型不匹配'
                    }else{
                         this.errormessage='文件为空'
                    }
                    this.filepath=val.filePath
                    this.showfile=true
      } else{
        this.show2=false;
        this.ruleForm.path = val.filePath;
        this.ruleForm.filePath = val.filePath;
        this.$notify({
                       title: '成功',
                       message:'文件上传成功！',
                       type:'success',

                    });
      }
    },
    loading2() {
      let params = {
        filePath: this.ruleForm.path,
        remarks: this.ruleForm.remarks,
        code: this.ruleForm.code,
        securityCode: this.securitycode2,
        payPassword : this.ruleForm.payPassword
      }
      this.post(params, 'services/app/applets/TransferAccountBatchsByExcel').then(rs => {
        console.log(rs)
        if (rs.success) {
          if(rs.result.state == 0){
            // this.$notify({
            //   title: '成功',
            //   message: '转账成功！',
            //   type: 'success'
            // });
           this.btnloading=false;
           this.dialogHeader2=true;
           this.$refs['ruleForm'].resetFields();
           this.$refs.uploadText.clearFiles();
          }
        } else {
            this.btnloading=false;
            let err = rs.error.message;
              this.$alert(err, {
                confirmButtonText: "确定",
                type: "warning"
              });
        }
      })
    },
    handleCurrentChange(val) {
      this.dataList(val)
    },
    submitForm(leadLabel) {
      this.$refs[leadLabel].validate(valid => {
        if (valid) {
          this.load(leadLabel)
          this.ensureloading=true;
        } else {
          return false;
        }
      });
    },
    submitSecond(ruleForm) {
      this.$refs[ruleForm].validate(valid => {
        if (valid) {
        
         this.loading2();
         this.btnloading=true;
        } else {
          return false;
        }
      });

    },
    load(leadLabel) {
      let params = this.formLabel
      params.selfCode = this.uuid;
      params.code = this.leadLabel.code;
      params.securityCode = this.securitycode;
      params.payPassword = this.leadLabel.payPassword;
      this.post(params, 'services/app/applets/UserTransfer').then(rs => {
        console.log(rs);
        this.ensureloading=false;
        if (rs.success) {
            // this.getBalance();
            this.centerDialogVisible = false;
            // this.$refs[leadLabel2].resetFields();
            this.dialogHeader=true;
            this.$refs['formLabel'].resetFields();
            // this.$notify({
            //   title: '成功',
            //   message: '发放成功！',
            //   type: 'success'
            // });
            // this.$router.go(0)
          }else{
			// this.centerDialogVisible = false;
            this.uuid = this.setbizid();
            this.ensureloading=false;
            let err = rs.error.message;
              this.$alert(err, {
                confirmButtonText: "确定",
                type: "warning"
              });
            // this.$notify.error({
            //   title: '失败',
            //   message: rs.error.errorMessage
            // });
          }
      })
    },
    getBalance() {
      let params = {};
      this.post(params, 'services/app/applets/SubAccountBalance').then(rs => {
        if (rs.success) {
           nubalanceData=rs.result.money
           let balanceData = this.numFilter(rs.result.money)
          this.balance = balanceData;
        }
      })
    },
    //限制上传一个文件
    handleExceed(files, fileList) {
              this.$message.warning(`当前限制上传1个文件`);
            },

    //第一个验证码发送
    getnumber() {
      let params = {}
      this.post(params, 'services/app/applets/SendSMSCodePC').then(rs => {
        if(rs.success){
            this.securitycode = rs.result.securityCode
            this.$message.success('验证码已发送，请注意查收');
        }else{
          this.timer1 = clearInterval(this.timer1);
        // this.count1 = TIME_COUNT;
        this.show1 = true;
        } 
      })
    },
    //第二个验证码发送
    getnumber3() {
      let params = {}
      this.post(params, 'services/app/applets/SendSMSCodePC').then(rs => {
        if(rs.success){
             this.securitycode2 = rs.result.securityCode
             this.$message.success('验证码已发送，请注意查收');
        }else{
            this.timer=clearInterval(this.timer);
            this.show=true;
        }
      })
    },

    userinfo() {
     
        let params = {
        id: this.id
      }

      this.post(params, 'services/app/applets/UserInfoById').then(rs => {
        console.log(this.$route.query.id)
        if(rs.success){
          this.formLabel.phoneNumber = rs.result.phoneNumber
          this.formLabel.name = rs.result.name
          this.formLabel.identityCard = rs.result.identityCard
        }
       
      })
  },
    determine(formLabel) {
      this.uuid = this.setbizid();
      // this.centerDialogVisible = true;
      this.$refs[formLabel].validate((valid) => {
        if (valid) {
          this.queding(formLabel)
        } else {
          return false;
        }
      });
    },
    queding() {
      let params = {
        name: this.formLabel.name,
        phoneNumber: this.formLabel.phoneNumber,
        identityCard: this.formLabel.identityCard,
      }
      this.post(params, 'services/app/applets/UserTransferVaild').then(rs => {

        if (rs.success) {
          this.centerDialogVisible = true;
          this.$refs.singleTable.setCurrentRow();
        }

      })

    },
    AdminInfo(){
        let params={};
        this.post(params,'services/app/applets/AdminInfo').then(rs=>{
            if(rs.success){
                this.phone=rs.result.smsPhoneNumber 
            }
        })
    },
    setbizid() {
      var s = [];
      var hexDigits = "0123456789abcdef";
      for (var i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
      }
      s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
      s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
      s[8] = s[13] = s[18] = s[23] = "-";
      var uuid = s.join("");
      return uuid;
    }
  },




}

</script>
<style lang="scss" scoped>
.wd250 {
  width: 250px;
}

.up-text{
                color:#333;
                font-size: 24px;
                text-align: center;
                margin-top: 8px;
                margin-bottom:8px;
            }；
  

.setColor{
  color:#999;
}

.unit-ment {
.area{
    font-size: 13px;
}
.up-img{
                text-align: center;
                margin-top: 10px;
                img{
                    width:60px;
                    height: 60px;
                }
            };
  background-color: #fff;
  .sms {
    padding: 5px;
    border-radius: 3px;
    border: 1px solid;
    font-size: 12px;
  }
  .el-upload el-upload--text {
    line-height: 3;
  }
  .uti-table {
    margin-left: 20px;
    margin-right: 20px;
    color: #333;
    font-size: 13px;
  }
  .biaoge {
    width: 600px;
    margin-left: 52px;
    .genblance {
      margin-bottom: 28px;
    }
    .dmodel {
      margin-left: 115px;
      margin-bottom: 28px;
      display: inline-block;
      color: #606266;
    }
    .model-message{
        color: red;
    }
    .file {
      float: left;
    }
    .daoru {
      font-size: 13px;
      margin-right: 20px;
      margin-left: 58px;
      color: #606266;
    }
  }

  .detail {
    color: #027dca;
  }
  .el-form-item {
    margin-bottom: 28px;
  }
  .circle1 {
    color: #cf1322;
    font-size: 14px;
  }
  .circle {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: #cf1322;
    margin-right: 10px;
  }
  .singleLayout{
    .formPlace{
        position: relative;
        .placeChange{
            position: absolute;
            top: 3px;
            right: -75px;
        }
    }
    width: 600px;
    .layout1 {
    .formSearchDiv{
            display: inline-block;
            margin-bottom: 30px;
        }
    .ensurebtn{
        clear: both;
        text-align: center;
        margin-top: 10px;
    }
    .page-right{
        float: right;
        margin-top: 30px;
        margin-bottom: 30px;
    }
    .searchdata{
        margin-left: 15px;
    }
    width: 400px;
    margin-left: 300px;
    .define {
      margin-left: 200px;
    }
    .form {
      float: left;
      width: 520px;
      .el-form-item__label {
        padding-right: 20px;
      }
      .el-input__inner {
        padding-left: 8px;
      }
      .el-textarea__inner {
        padding-left: 8px;
        width: 420px;
        height: 280px;
      }
      .inputbox {
        width: 420px;
        height: 28px;
      }
    }
  }
  }
  
  .btn2 {
    margin-top:40px;
    margin-left: 200px;
    margin-bottom:30px;
  }
  .layout {
    .biaoge {
      margin-left: 300px;
    }
    .clearfix:after {
      content: "";
      display: block;
      clear: both;
    }
    .verification {
      margin-right: 15px;
    }
    .notice2 {
      margin-left: 100px;
      float: left;
      color: #555;
      font-size: 13px;
      .notice3 {
        margin-top: 20px;
        a {
          color: #027dca;
        }
      }
    }
  }

  .block {
    width: 400px;
    display: block;
    margin: 25px 0;
  }
  .bottom {
    text-align: center;
    .getcheck1 {
        margin: 25px auto;
        width: 370px;
    }
    .check {
      font-size: 17px;
      margin-left: 82px;
    }
    .btn1 {
      display: inline-block;
      margin-bottom: 37px;
    }
    .bdload {
      text-align: center;
    }
  }

  .unit-tabs {
    width: 100%;
    border-bottom: 1px solid #d7d7d7;
    padding: 0 0;
    margin-bottom: 30px;
    .tabs1 {
      line-height: 50px;
      width: 150px;
      display: inline-block;
      font-size: 16px;
      margin-top: 9px;
      text-align: center;
      margin-left: 20px;
      font-weight: 500;
      cursor: pointer;
      margin-bottom: -1px;
    }
    .tabs2 {
      line-height: 50px;
      width: 150px;
      display: inline-block;
      font-size: 16px;
      text-align: center;
      margin-left: 20px;
      font-weight: 500;
      cursor: pointer;
      margin-bottom: -1px;
    }

    .unit-tabs-act {
      color: #ff8819;
      background: url(../../assets/images/bomactive2x.png) center 41px no-repeat;
    }
  }
  .paging {
    width: 100%;
    text-align: right;
    margin-top: 52px;
    padding-right: 2px;
  }
  .model {
    clear: right;
    position: relative;
    line-height: 2;
    .downloadModel {
      position: absolute;
      top: 0;
      left: 122px;
      color: #606266;
    }
    .el-upload-list__item-name {
      padding-left: 0;
    }
    .lead {
      width: 250px;
      height: 105px;
    }
    .model1 {
      color: #027dca;
    }
    .model2 {
      position: absolute;
      top: 3px;
      right: -149px;
    }
  }
}

</style>
